package com.major.thread;

import java.util.concurrent.Callable;
import java.util.concurrent.FutureTask;

public class ThreatTest implements Runnable {
    @Override
    public void run() {
        System.out.println("实现启动" );
    }

    private static int i = 0;

    public static void main(String[] args) throws Exception{

        Thread thread1 = new Thread(new ThreatTest());
        //thread1.start();

        Thread thread2 = new ThreadTest02();
        //thread2.start();

        System.out.println("主线程启动");

        ThreatTest.i--;

        Callable<Integer> callable = new ThreadTest03();
        FutureTask<Integer> task = new FutureTask<>(callable);

        Thread thread03 = new Thread(task);
        thread03.start();

        Object o = task.get();
        System.out.println(o);


    }
}

class ThreadTest02 extends Thread {
    @Override
    public void run() {
        System.out.println("extend run");
    }
}

class ThreadTest03 implements Callable<Integer>{

    @Override
    public Integer call() throws Exception {

        System.out.println("callable run");
        Thread.sleep(1000 * 3);
        return 5;

    }
}
